﻿using System;
using System.Collections.Generic;
using System.Text;
using Zjh.PackSerializer.Converters;
using Zjh.PackSerializer.Converters.Base;

namespace Zjh.PackSerializer
{
    public class PackSerializerFactory
    {
        public static IPackSerializer DefaultSerializer { get; }
        static PackSerializerFactory()
        {
            var serializer = new PackSerializer();
            serializer.Converters.Add(new PackContractConverter());
            serializer.Converters.Add(new Int16Converter());
            serializer.Converters.Add(new Int32Converter());
            serializer.Converters.Add(new Int64Converter());
            serializer.Converters.Add(new UInt16Converter());
            serializer.Converters.Add(new UInt32Converter());
            serializer.Converters.Add(new UInt64Converter());
            serializer.Converters.Add(new SingleConverter());
            serializer.Converters.Add(new DoubleConverter());
            serializer.Converters.Add(new StringConverter());
            serializer.Converters.Add(new DateTimeConverter());
            serializer.Converters.Add(new ByteConverter());
            serializer.Converters.Add(new BooleanConverter());
            serializer.Converters.Add(new EnumConverter());
            DefaultSerializer = serializer;
        }

        public static IPackSerializer CreateSerializer(IEnumerable<IPackConverter> converters)
        {
            var serializer = new PackSerializer();
            serializer.Converters.AddRange(converters);
            return serializer;
        }
    }
}
